#include <stdio.h>

int main()
{
  int a, b;
  int tmp = 0;
  scanf("%d %d", &a, &b);
  if (a < b)
  {
   tmp = a;
   a = b;
   b = tmp;
  }

  while (tmp = a % b)
  {
    a = b;
    b = tmp;

  }
  printf("%d", b);
}
